package com.zx.viewlearn.activity;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Toast;

import com.zx.viewlearn.R;
import com.zx.viewlearn.views.MyView1;

/**
 * 自定义view，几种移动方式
 */
public class ViewLearnActivity1Move extends AppCompatActivity {
    MyView1 myView1;

    public ViewLearnActivity1Move() {

        Log.e("ViewLearnActivity1Move", "ViewLearnActivity1Move()");
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_view_learn1);
        myView1 = findViewById(R.id.myView1);
        //view动画,属性没有变，onclick事件，还在原来位置
//        myView1.setAnimation(AnimationUtils.loadAnimation(this, R.anim.translate));
        //属性动画,属性改变，onclick事件，在变幻后位置
//        ObjectAnimator.ofFloat(myView1, "translationX", 0, 300).setDuration(1000).start();
        myView1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(ViewLearnActivity1Move.this, "哈哈", Toast.LENGTH_SHORT).show();
            }
        });
    }
}
